08a999ca5ad362bdf122dd983a7249eb7fc347ae
1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # Remembership module for OpenERP, Membership module enhancement and bug fixes
5 # Copyright (C) 2012-2013 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
7 # This file is a part of Remembership
9 # Remembership is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # Remembership is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ##############################################################################
24 from openerp
.osv
import osv
25 from openerp
.osv
import fields
26 from datetime
import datetime
29 class membership_invoice(osv
.osv
):
30 _inherit
= 'membership.invoice'
33 'date_from': fields
.date('This membership start date'),
34 'is_date2date': fields
.boolean('This membership product is date to date.', readonly
=True),
38 'date_from': datetime
.today().strftime('%Y-%m-%d'),
41 def onchange_product(self
, cr
, uid
, ids
, product_id
=False):
42 res
= super(membership_invoice
, self
).onchange_product(cr
, uid
, ids
, product_id
)
44 res
['value']['is_date2date'] = self
.pool
.get('product.product').browse(cr
, uid
, [product_id
], context
=None)[0].membership_date2date
46 res
['value']['is_date2date'] = False
50 def membership_invoice(self
, cr
, uid
, ids
, context
=None):
51 """NOTE: Copy of orginial function for overwrite it by adding
52 date_from value for date to date membership products. Keep an eye of it
53 for taking advantage of its enhancements (2013-01-11)"""
54 mod_obj
= self
.pool
.get('ir.model.data')
55 partner_obj
= self
.pool
.get('res.partner')
59 data
= self
.browse(cr
, uid
, ids
, context
=context
)
63 'membership_product_id': data
.product_id
.id,
64 'amount': data
.member_price
,
65 'date_from': data
.date_from
67 invoice_list
= partner_obj
.create_membership_invoice(cr
, uid
, context
.get('active_ids', []), datas
=datas
, context
=context
)
69 res
= mod_obj
.get_object_reference(cr
, uid
, 'account', 'view_account_invoice_filter')
72 'domain': [('id', 'in', invoice_list
)],
73 'name': 'Membership Invoices',
75 'view_mode': 'tree,form',
76 'res_model': 'account.invoice',
77 'type': 'ir.actions.act_window',
78 'search_view_id': res
and res
[1] or False